package com.lex.jfb;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2016/5/23.
 */
public class SaoMa_JiFenActivity extends AppCompatActivity{
    private ListView recordListView;

    private String KEY_RECORD_NAME="name_1";
    private String KEY_RECORD_COUNTS="name_2";
    private String KEY_RECORD_TIME="name_3";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tianchongliebiao);
        findView();
        initView();
}
    private void findView(){
        recordListView = (ListView) findViewById(R.id.integral_record_1);
    }
    private void initView(){
        final List<Map<String,String>>data = new ArrayList<>();
        for (int i = 0;i < 20; i++){
            Map<String,String>map1 = new HashMap<>();
            map1.put(KEY_RECORD_NAME,"扫码积分"+i);
            map1.put(KEY_RECORD_COUNTS,"+"+(10+i));
            map1.put(KEY_RECORD_TIME,"2016/3/25 19:00");
            data.add(map1);
        }
        SimpleAdapter recordAdapter = new SimpleAdapter(this,data,R.layout.activity_saoma_jifen,
                new String[]{KEY_RECORD_NAME,KEY_RECORD_COUNTS,KEY_RECORD_TIME},
                new int[]{R.id.integral_1,R.id.record_1,R.id.time_1});
        recordListView.setAdapter(recordAdapter);

        recordListView.setOnItemClickListener(new AdapterView.OnItemClickListener(){
            public void onItemClick(AdapterView<?>parent,View view,int position,long id){
                Toast.makeText(SaoMa_JiFenActivity.this,"你点击了第"+position+"个记录",Toast.LENGTH_SHORT).show();
            }
        });

        recordListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener(){
            public boolean onItemLongClick(AdapterView<?>parent,View view,int position,long id) {
                Toast.makeText(SaoMa_JiFenActivity.this, "你长按了第" + position + "个记录", Toast.LENGTH_SHORT).show();
                return false;
            }
        });
    }

}
